package org.jeecg.modules.chvegetable.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.chvegetable.entity.FlowerTagBook;
import org.jeecg.modules.chvegetable.mapper.FlowerTagBookMapper;
import org.jeecg.modules.chvegetable.service.IFlowerTagBookService;
import org.jeecg.modules.flower.entity.FlowerTagInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 采后台账表
 * @Author: jeecg-boot
 * @Date:   2023-02-07
 * @Version: V1.0
 */
@Service
public class FlowerTagBookServiceImpl extends ServiceImpl<FlowerTagBookMapper, FlowerTagBook> implements IFlowerTagBookService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer inBooks(String mainID,boolean isIn) {
        if(isIn) {
            return baseMapper.inBooks(mainID);
        }else{
            return baseMapper.inBooksBack(mainID);
        }
    }
//锁定占用台账数量
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer lockTagnumfroOut(String mainID) {
        return baseMapper.lockTagnumfroOut(mainID);
    }
//归还占用数量
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer lockTagnumfroOutBack(String mainID) {
        return baseMapper.lockTagnumfroOutBack(mainID);
    }

    //    获取库存不够的产品，根据出库单id
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<FlowerTagBook> getLowBookList(String id) {
        return baseMapper.getLowBookList(id);
    }
    //    获取库存不够的产品，根据 预出库单id
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<FlowerTagBook> getLowBookListPre(String id) {
        return baseMapper.getLowBookListPre(id);
    }
//    出库单扣减库存---
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer subBookInfoFromOutOrder(String id) {
        return baseMapper.outForOutOrder(id);
    }
//    出库单扣减库存--- 撤销
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer subBookInfoFromOutOrderBack(String id) {
        return baseMapper.outForOutOrderBack(id);
    }
//    预出库=====单扣减库存---
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer subBookInfoFromOutOrderPre(String id) {
        return baseMapper.outForOutOrderPre(id);
    }
//    预出库=====单扣减库存---撤销
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer subBookInfoFromOutOrderPreBack(String id) {
        return baseMapper.outForOutOrderPreBack(id);
    }
//    校验台账数据 是否为负
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer checkBooksIsErr() {
        return  baseMapper.checkBooksIsErr();
    }
    @Override
    public FlowerTagBook getTOtal(Wrapper<FlowerTagBook> wrapper) {
        return  baseMapper.getTotal(wrapper);
    }
}
